###########################################
#REPLICATION FILE FOR VOX POPULI, VOX DEI?
#by ADAM RAMEY
#SECTION 5 ESTIMATION
###########################################

################################################################
#This file estimates politician and voter ideal points for 2012
################################################################

rm(list=ls())
detach(cces)


library(foreign)
library(Zelig)
library(MCMCpack)
library(reshape)
library(basicspace)
library(ggplot2)

rm(list=ls())
detach(cces)

##be sure to change the line below so as to indicate where the data and scripts are
setwd("~/Downloads/Replication Materials/")
load("CCES 2012.Rda")

attach(cces)


##Run the three separate scalings

source("~/Downloads/Replication Materials/Estimation for Congress/Scaling House Members Aldrich-McKelvey 2012.R")
source("~/Downloads/Replication Materials/Estimation for Congress/Scaling Senators Aldrich-McKelvey 2012.R")
source("~/Downloads/Replication Materials/Estimation for Congress/Scaling Governors Aldrich-McKelvey 2012.R")



##Make sure to add the voter ideal points to the data...
cces$respondent_ideal_point <- ideal_points

##Also, add CD variable to dataset
cces$cong_district <- paste(inputstate,"-d-",as.numeric(cdid),sep="")

##Write out data...
save(cces, file="CCES 2012.Rda")
